const path = require("path");

function resolve(dir) {
  return path.join(__dirname, ".", dir);
}
const SPDAPIURL = 'http://spd-gateway:9999'

module.exports = {
  webpack: function override(config) {
    //配置别名
    config.resolve.alias = {
      "@": resolve("src"),
    };
    return config;
  },

  devServer: function (configFunction) {
    return function (proxy, allowedHost) {
      const config = configFunction(proxy, allowedHost);
      config.proxy = {
        "/api": {
          // 配置网关地址
          target: SPDAPIURL,
          ws: true,
          changeOrigin: true,
          pathRewrite: {
            "^/api": "",
          },
        },
      };
      return config;
    };
  },
};
